#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;
const int N = 5e6+10;	

ll n, p, a[N], b[N];

int main()
{
	cin >> n >> p;
	for(int i=1; i<=n; i++)
	{
		cin >> a[i];
		b[i]=a[i]-a[i-1];
	}
	while(p--)
	{
		int l, r, c;
		cin >> l >> r >> c;
		b[l]+=c, b[r+1]-=c;
	}
	ll sum=0, ans=0x3f3f3f3f;
	for(int i=1; i<=n; i++)
	{
		a[i]=b[i]+a[i-1];
		ans=min(ans, a[i]);
//		cout << a[i] << ' ';
	}
	cout << ans;
	return 0;
}